﻿// Write a program that extracts from a given text all sentences containing given word.
// Consider that the sentences are separated by "." and the words – by non-letter symbols.

using System;
using System.Linq;
using System.Text.RegularExpressions;

public class GetAllSentencesContainWord
{
    public static void Main()
    {
        string text = "We are living in a yellow submarine. We don't have anything else. Inside the submarine is very tight. So we are drinking all the day. We will move out of it in 5 days.";
        string word = "in";

        string patternSentence = @"([A-Z][^\.!?]*[\.!?])";
        string patternWord = string.Format(@"\b{0}\b", word);
        foreach (Match sentence in Regex.Matches(text, patternSentence))
        {
            if (Regex.IsMatch(sentence.ToString(), patternWord))
            {
                Console.WriteLine(sentence);
            }
        }
    }
}